﻿using UnityEngine;
using System.Collections;

public class AudioCtrl : MonoBehaviour
{
    public AudioSource asr;
    public float length;
    // Use this for initialization
    void Start()
    {
        if (!asr.loop)
        {
            Destroy(gameObject, length);
        }
        asr.Play();
    }

    // Update is called once per frame
    public void SetInfo(string clipName, bool isLoop, float volume, bool is3D, float maxDis)
    {
        asr.clip = Resources.Load<AudioClip>("Sound/" + clipName);
        length = asr.clip.length + 1;
        asr.loop = isLoop;
        asr.volume = volume;
        asr.spatialBlend = is3D ? 1 : 0;
        asr.maxDistance = maxDis;
    }
}
